package com.xspace.android.xafcommon.view;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.PagerAdapter;
import android.view.ViewGroup;

import java.util.ArrayList;

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {
	private ArrayList<Fragment> fragmentsList;
	private FragmentManager fm;
	public MyFragmentPagerAdapter(FragmentManager fm) {
		super(fm);
		this.fm=fm;
	}

	public MyFragmentPagerAdapter(FragmentManager fm,
								  ArrayList<Fragment> fragments) {
		super(fm);
		this.fragmentsList = fragments;
		this.fm=fm;
	}
	@Override
	public int getCount() {
		return fragmentsList.size();
	}

	@Override
	public Fragment getItem(int arg0) {
		//Log.v("install", "MyFragmentPagerAdapter getItem position:"+arg0);
		return fragmentsList.get(arg0);
	}

	@Override
	public int getItemPosition(Object object) {
		//return super.getItemPosition(object);
		return PagerAdapter.POSITION_NONE;
	}

	public void setFragmentsList(ArrayList<Fragment> fragmentsList) {
		this.fragmentsList = fragmentsList;
	}

	@Override
	public Object instantiateItem(ViewGroup container, int position) {
		//Log.v("install", "MyFragmentPagerAdapter instantiateItem position:"+position);
		return super.instantiateItem(container, position);
	}
	
}
